<template>
  <div>
    账号：<input type="text" v-model="login.account" /> 密码：<input
      type="text"
      v-model="login.pwd"
    />
    <button @click="goLogin">登录</button>
    <button @click="$router.push('/reg')">注册</button>
  </div>
</template>

<script>
import request from '../request/index.js'
export default {
  data() {
    return {
        login:{
            account:'shui',
            pwd:'shui'
        },
        userInfo:{}

    };
  },

  created() {
      //console.log(this.$store.state.userInfo)
  },
  methods: {
       async goLogin(){
             const {data:res}= await request({url:"/users/logincheck",method:"post",data:this.login })
             if(res.status!=0) alert('账号密码错误')
             this.userInfo=res.table
             this.userInfo.token=res.token
             //console.log(res)
             //console.log(this.userInfo)
             this.$store.commit("saveUserInfo",this.userInfo)
             this.$router.push('/myuser')
       }
  },
};
</script>
<style scoped>
</style>